A method of gas sensor drift compensation based on intrinsic characteristics of response curve

Sensor drift, which is an inevitable and challenging problem in gas sensing, seriously affects the detection performance of sensor. In this study, a new sensor drift compensation method, which is based on intrinsic characteristic of sensory response, is proposed. The dataset of gas sensor for two types of gas with a period of 36 months are collected and two features (one is steady-state feature, another is transient feature) are extracted. Their relationship, which is found to be certain for different months and sensors, is explored. Then, drift compensation method is processed based on this relationship, aiming to make the drifted sensor features adjusted to that of month 1, which is considered as having no drift phenomenon. Moreover, small amount of dataset is necessary for model building and it has strong scalability. Finally, SVM is employed for proving the performance of the drift compensation method proposed in this study. The results show the efficacy of 22 month of continuous monitoring, which has been enough for most application scenario, and almost 20% of increasement of correct classification rate of SVM after drift compensation, which indicates the effect of drift compensation method.

Sensor is a way obtaining information, which is a basic and important tool in information age and has been largely applied in many areas 1,2 . Gas sensor is an indispensable kind of sensor, which is a nondestructive and rapid detection way, having aroused wide concern from researchers due to its close relation to practical applications. Because of those advantages, it has been successfully applied in many areas, such as air quality monitoring 3 , drunk driving 4 , food quality detection 5 , and so on.
Sensor drift is a phenomenon that sensory signal response would gradually and unpredictably change even exposed to the same analyte under identical condition when sensors are operated over a long period of time 6 . Furthermore, sensor drift is an inevitable problem, which is the characteristic of sensor itself and has plagued the sensor research community for many years. Existing types of gas sensor 7,8 all belong to chemical sensor, where sensor drift is a serious impairment.
In general, sensor drift can be attributed to two predominant sources 910 : real drift and measurement system drift. The real drift is the main one, which happens due to the chemical and physical interaction processes of the chemical analytes, occurring at the sensing film microstructure. The measurement system drift is produced by the external and uncontrollable alterations of the experimental operating system.
Promoting anti-drift performance of sensor material and proposing a method for drift compensation are two main ways for solving this problem. Developing a new sensor material is cost-consuming and time-consuming. By contrast, proposing a method for drift compensation is relatively easy and has high feasibility. Hence, many studies have been done for drift compensation and two main ways are proposed, which are divided into based on providing reference gas or not.
Drift compensation method based on reference gas is relatively traditional, whose data processing is simple and rapid. Furthermore, acceptable results could be obtained. Ziyatdinov et al. 11 proposed drift compensation methods based on common principal component analysis combined with reference gas. Good results were obtained. However, practically more devices are needed for supplying extra reference gas, which increases the detection cost and makes the detection process more complicated. Moreover, the choosing of reference gas is another problem. They limit its application scenarios.
For the drift compensation method without reference gas, it is always complex relatively and many studies also have been done. Liu, Chaibou, and Huang 12 proposed a novel retraining method of multiple self-organizing maps for gas sensor drift compensation. Liu  In this paper, a novel drift compensation method based on intrinsic characteristics of response signal, which proceeds without reference gas, is proposed. A parameter, which reflects intrinsic characteristics of gas sensor response signal, is researched. This parameter is invariant for certain sensor and detection time. Furthermore, drift compensation and classification methods are built separately, leading to small amount of training dataset requirement for model building and good model extension ability when other categories include. Moreover, classification algorithm is applied for proving the performance of the new proposed method. The aims of this paper are: (1) to explore the intrinsic characteristics of response signal; (2) to propose a new method realizing drift compensation through intrinsic characteristics; (3) to evaluate the drift compensation performances through support vector machine (SVM) 15 .

Data acquisition and processing
Data acquisition. The experiment was carried out during January 2019 to December 2021 (36 months) in a gas delivery platform facility. Eight gas sensors were applied for collecting dataset and two kinds of gases (Ethanol and Ethylene) were tested. The sensors, which were metal-oxide semiconductor (MOS) gas sensors, were bought from Figaro Inc. and the model numbers were TGS 2600, TGS 2602, TGS 2603, TGS 2610-C00, TGS 2611-C00, TGS 2612-D00, TGS2620 and TGS 2630, respectively. For each sensor, the heater module is integrated in sensor for temperature control and 65% RH (relative humidity) is also required for test gas, making the detection environment stability.
In detail, their features display in Table 1 below. All the sensors have response to gases Ethanol and Ethylene. The target gases are the ones that corresponding sensor sensitive to. For gas Ethanol, sensor TGS 2600, TGS 2602, TGS 2603, TGS2620 and TGS 2630 have high sensitivity. For gas Ethylene, there is not specific sensor corresponding to. However, the combination of eight sensors gives comprehensive information, making it feasible for Ethylene detection.
The sensors were placed in a 60 ml-volume closed container, which contained inlet and outlet for gas passing through. The flow level of each gas was set as 100 ml/min, ± 1% of accuracy. All the gases were stored in pressurized gas cylinders. Synthetic air was applied as background gas and two tested gases were added to it for all experiment. Moreover, the relative humidity of the tested gas was controlled in 65%. Furthermore, for obtaining stable and effective results, the response of the gas sensor array was measured after seven days preheating period, which is attained via a built-in heater. More details could be seen from the product information at https:// www. figar osens or. com/ produ ct/ sensor/.
For the detection time, 600 s were applied for the gas injection and 500 s for the recovery (cleaning). The sampling rate was set to 60 Hz. The dataset during a period of month 1, 4, 14, 16, 20, 22, 36 was collected and employed for drift compensation research. The data of month 1 was taken as the benchmark, which considered as no drift. The data of month 4 showed the characteristic of the initiating. While, the data of month 14, 16, 20 and 22 showed that of intermediate stage. The data of month 36 showed the characteristic of end stage. The number of samples collected during a period of one month for two gases are showed in Table 2 below.
For model building and testing, the dataset is divided into training set and testing set. 25 samples of each month and gas were selected and applied for model building. Other samples were applied for model testing.
Data processing. Feature extraction. Feature extraction 16 is an extremely important and inevitable preprocessing step for exploring the data characteristic and applying in real application 17 . Figure 1 shows a typical response curve of gas sensor, which is also the data collected for analysis.
According to Fig. 1, for gas injection (adsorption) phase, the curve increases first, then become stable. For the cleaning (desorption) phase, the curve decreases first and then returns to the initial stage. Furthermore, the www.nature.com/scientificreports/ trends of the original curve and drifted curve are similar. On the other hand, the curve trend of desorption phase is largely depended on the characteristic of adsorption phase. The higher stable value means the higher slope values of adsorption and desorption phase. Hence, for reducing the calculation quantity, the data of response curve of adsorption phase are applied for feature extraction. By contrast, the main difference between them is the stable value and slope of response curve. Hence, four features (one steady-state and three transient features) are selected for drift compensation research in this study. The steady-state feature is defined as the difference of the maximal response value and the baseline.
where Fs represents the steady-state feature, Max(R) is maximal response value, Min(R) is the baseline of response curve.
Its normalized version is expressed by the ratio of the maximal response value and the baseline value.
where Fs represents the normalized version of steady-state feature. The transition feature reflects the dynamics of sensor response and is evaluated based on exponential moving average. The equation presents below.
where n is the detection time point. R n is response value when detection time point is n. α is the scaling parameter, which amplifies the rising amplitude of adjacent response values, and defined as 0.1, 0.01 and 0.001, respectively. S n could be considered as the parameter containing information of R n and R n + 1 -R n . Hence, F n describes the rising amplitude of response value. All the F n are calculated and the average of them is defined as transition feature. Then, three transition features are calculated through three scaling parameters, respectively.
Sensor drift compensation method. The process of this method is as follows: (1) Feature extraction and selection: According to the method described above, four features have been extracted, and two of them are selected (one is the steady-state feature, defined as Feature 1 and another is the transient feature, defined as Feature (2) based on the correlation of steady-state feature and transient feature for subsequent analysis.
(1)  where P(j)(k) is the scaling coefficient of sample j of Month k. Equation (7) is proposed based on Eq. (1). Hence, P(j)(k) should be transformed, making it as close as possible to A for drift compensation. The transformation equation is as follows: where P(k) , which is average value of P(j)(k) , could be considered as the actual scaling coefficient of Month k. Equation (8) makes the value of P(j)(k) move towards to the value of A(j) , which is the scaling coefficient of sample j of Month 1. Therefore, M(j)(k) could be considered as the actual scale coefficient of sample j of month k. Real drift and measurement system drift are two predominant sources causing sensor drift. M(j)(k) decreases the real drift. However, the measurement system drift is still existed. Hence, a new parameter is introduced and its equation is as follows: where N(i)(j) is final scale coefficient. In Eq. (9), M(j)(k) and A decrease the real drift and measure system drift respectively, making the compensated result more accurate.
where According to this method building process, the amount of dataset for model building is small. In this study, 25 samples of each month and gas were selected and applied. Furthermore, the drift compensation and group classification methods are separated leading to strong scalability. Support vector machine. SVM, which is based on the Structural Risk Minimization and Statistic Learning Theory, is considered as one of the most robust and accurate methods used for classification analysis 18 . Furthermore, it has global minimum of the error function and excellent generalization ability of the trained network 19 . www.nature.com/scientificreports/ It is a linear machine working in the high dimensional feature space formed by the non-linear mapping of the n-dimensional input vector x into a K-dimensional feature space (K > n) with a function. For the results of SVM, samples are considered as points in space and mapped so that the samples of the separated categories are divided by a clear gap that is as wide as possible, which is also the optimal hyperplane to separate two classes.

Results and discussion
In this part, the sensor drift compensation method proposed is carried out and its performance is discussed according to the results of SVM. Month 1 is set as benchmark, which is considered as no drift. The objective of the drift compensation method is to make the characteristics of features of other months similar to those of month 1.
The data analyzed in this study are: eight steady features and twenty-four transient features in total, which are extracted from eight sensor response curves for representing one sample. Based on Eq. Linear correlation leads to less calculation complex and displays a more obvious visual effect. Hence, it is preferentially applied for selecting appropriate Feature 2. As shown in Fig. 2a, b and c, all plots display strong correlation, which proves the correctness of linear relationship of these two features. Figure 2a, b and c are the linear relationship of Feature 1 and three transient features with 0.001, 0.01 and 0.1 of scaling parameter, respectively. The fitting correlation coefficients (R 2 ) and root mean square error (RMSE) are employed to reflect their fitting performance. According to Fig. 2, Fig. 2a has the best fitting performance, whose standard error is 0.06736, R 2 is 0.9951. By contrary, Fig. 2c has the worst fitting performance. The reason might be that as the increasement of the scaling parameter α , more uncertainty includes, which makes the data fluctuate more greatly. However, the smaller scaling parameter means higher computing cost. For Fig. 2b, its standard error is 0.1348 and R 2 is 0.9918, which is just a little worse than that of Fig. 2a and also shows good fitting performance. Hence, considering both the fitting performance and calculation complex, the feature with 0.01 of scaling parameter is selected and defined as Feature 2.   www.nature.com/scientificreports/ The fitting performance of Month 1 is the most important index for the reason of that it is the drift compensation objective. According to Table 3, the values of R 2 of Month 1 are all higher than 0.86, which indicates good correlation and that parameter A is able to reflect the characteristic of sensor signal response of Month1. Furthermore, values of R 2 are all acceptable, which proves the correctness of linear correlation of two features again. According to Table 4, the values of RMSE of Month 1 are all less than 0.12, which means a good fitting performance. For all the values in Table 4, most of RMSE are less than 0.15, which also proves the existence of linear correlation of two features.

Calculation of
On the other hand, based on Tables 3 and 4, the fitting performance of Month 1 is the best. For other months, the values of R 2 and RMSE are fluctuated and most of their fitting performances are worse than that of Month 1. The reason might be environment and measurement system factors, whose uncertainty makes the sensor drift fluctuated.
According to the description above, the relationship of Feature 1 and Feature 2 exists. Furthermore, their relationships for different months and sensors are different, which means that it could be taken as a characteristic for drift compensation. As described in "Data Acquisition", 25 samples of each month and gas are selected and applied for parameters A and B(k) calculation.
Parameter A reflects the relationship of two features of the same sensor. The values of parameter A with different sensors and months are calculated by Eq. (4) and presented for showing drift phenomena directly and analyzing the drift rule of sensor. Their trends with different months and sensors show in Fig. 3 below.
As shown in Fig. 3, parameter A's trends of all sensors are similar, which reflects the similarity of drift phenomena. Moreover, the value of parameter A increases first, then fluctuates and finally decreases. For first several months, sensor drift might be influenced by both real drift and measurement system drift, which causes uncertainty and unpredictable. Hence, the values of parameter A fluctuate during this period. Then, drift caused by real drift become dominated with time goes, which has a certain trend and leads to the decrease of the value of parameter A. The results indicate that all sensors have similar drift rule and parameter A is a suitable parameter exhibiting it.
B(k) , which reflects the relationship of the Feature 1 of Month 1 and other months, is another important parameter for drift compensation and employed to judge drift degree. The value trends of B(k) with different sensors and months show in Fig. 4 below.
As shown in Fig. 4, the trends of B(k) for all sensors are also similar. It fluctuates first, then become stable. Moreover, the value of B(k) during month 14 to 20 decreases greatly, which increases the drift compensation Table 4. The value of RMSE of different months and sensors.  The results show that the average of initial feature of month 14 is 5537.32, and its standard error is 2270.74. After drift compensation, its average value becomes 10,599.53, and its standard error is 5740.68. By comparison, the average value of month 1 is 11,149.45, and its standard error is 5102.03, which are similar to those of the dataset after drift compensation. The results prove the effect of the drift compensation method proposed in this study.

Month ID
Furthermore, the drift compensation features of other months also have similar characteristics, which indicates that the drift compensation method proposed in this study is reliable with high probability.
SVM. Feature 1 of all sensors and samples are compensated based on the process above. Then, SVM is applied and the classification performances of original dataset and drift compensated dataset are compared for proving the effect of drift compensation method.
For SVM, 180 samples (60 samples for Ethanol, Ethylene and background air, respectively) of Month 1 were selected and applied for building classification model for the reason of that the data of month 1 was the benchmark without drift. The same number of samples of each group helped to balance the importance of each group and improve the classification performance of SVM model. The kernel function was set as Radial Basis Function. For obtaining the optimal SVM model, two parameters, penalty parameter c and kernel parameter g, were optimized through grid search method with the growth of c and g at an interval of 2.5 for obtaining the best c and g. Five-fold cross-validation was applied to estimate the performance of each parameter and the parameters with best cross-validation accuracy were picked. Figure 5 shows the performance of SVM with different combinations of c and g. As shown in Fig. 5, 100% of classification correct rate is obtained when c = 0.1768 and g = 32, which are therefore applied for testing process.
Then, SVM built in previous sentence was applied for classification and the total samples showed in Table 2 were involved. Table 5 presents the results of SVM based on the original dataset and dataset after compensated.
As shown in Table 5, the correct classification rates of the dataset of Month 1 are both 100%, which indicates that SVM has good classification performance and proves the effect of SVM. For other months, the original data could be considered as drifted one, whose correct classification rates are all lower than that of Month 1. On the other hand, the results show that the classification performances of compensated data are better than that of the original data for all months, which indicates the effect of this drift compensation method.
In detail, for original data, its correct classification rates decrease as time goes overall. The reason might be that the drift phenomenon become more and more obvious, making SVM model lose efficacy gradually and leading to the decrease of its correct classification rate. For Month 20, its correct classification rate is 56.04%, which has become almost uselessness for the classification of original data. For the compensated data, the correct classification rate obtains more than 20% of increasement compared with that of original data except Month 36 and the average of them reaches to 89.78%, which reflect the good performance of drift compensation method. However, the correct classification rate also decreases as time goes, which indicates that the drift degree could influence the performance of drift compensation method and this influence became bigger with time goes. www.nature.com/scientificreports/ As to certain month, the correct classification rates of Month 20 and 22 are low for original data. By contrast, the value of B(k) , which is the main parameter for drift compensation, also decreases quickly during this period as shown in Fig. 4. Hence, the reason for bad results might be that the drift degree of original data of Month 20 and 22 has beyond the limit of SVM model. On the other hand, for compensated data, their classification correct rates are both acceptable, which prove that the drift compensation method is still worked in Month 22. For Month 36, the correct classification rate of compensated data is just a little higher than that of original data, which indicates the poor effect and that the drift compensation method does not work well.
According to the discussion above, the drift compensation method proposed in this study is effective when the continuous monitoring time less than 22 month, which has been enough for most application scenario. Hence, the drift compensation method proposed in this study achieves great development of correct classification rate and has practical significance.

Conclusion
Sensor drift is an inevitable problem in continuous monitoring application. In this study, a new drift compensation method, which is based on the intrinsic characteristics of response signal, is proposed. Small amount of dataset is necessary for model building and it has strong scalability. The dataset of month 1 is taken as no drift and the object of drift compensation. The results show that the characteristic of compensated dataset is similar to that of dataset of month 1, which indicates the efficacy of this method.
Then, SVM is applied for verifying the performance of drift compensation method. The results show almost 20% improvement of correct classification rate, reaching to 89.78%, and the efficacy of 22 month of continuous monitoring, which has been enough for most application scenario.
According to the results above, it is proved that the drift compensation method proposed in this study is effective and this study provides another way for sensor drift compensation.

Data availibility
The data that support the findings of this study are available from State Grid Corporation of China but restrictions apply to the availability of these data, which were used under license for the current study, and so are not publicly available. Data are however available from the authors upon reasonable request and with permission of State Grid Corporation of China.